﻿// <copyright file="DoubleIndexedProperty.cs" company="ALCPU">
// Copyright (c) 2010 All Right Reserved
// </copyright>
// <author>Arthur Liberman</author>
// <email>Arthur_Liberman@hotmail.com</email>
// <date>04-04-2010</date>
// <summary>Contains DoubleIndexedProperty class definition.</summary>

namespace Chess
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ChessDefinitions;

    /// <summary>
    /// A generic double indexed property class.
    /// </summary>
    /// <typeparam name="T">The type of the double indexed property.</typeparam>
    public class DoubleIndexedProperty<T>
    {
        /// <summary>
        /// The property value reference.
        /// </summary>
        private T[,] value;

        /// <summary>
        /// Initializes a new instance of the <see cref="DoubleIndexedProperty&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public DoubleIndexedProperty(T[,] value)
        {
            this.value = value;
        }

        /// <summary>
        /// Prevents a default instance of the <see cref="DoubleIndexedProperty&lt;T&gt;"/> class from being created.
        /// </summary>
        private DoubleIndexedProperty()
        {
        }

        /// <summary>
        /// Gets or sets the <paramref name="value"/> with the specified indexes i and j.
        /// </summary>
        /// <param name="i">The i parameter.</param>
        /// <param name="j">The j parameter.</param>
        /// <value>the value.</value>
        public T this[int i, int j]
        {
            get { return this.value[i, j]; }
            set { this.value[i, j] = value; }
        }

        /// <summary>
        /// Gets or sets the <see cref="T"/> at the specified <paramref name="position"/>.
        /// </summary>
        /// <param name="position">The i parameter.</param>
        /// <value>the value.</value>
        public T this[Position position]
        {
            get { return this.value[position.X, position.Y]; }
            set { this.value[position.X, position.Y] = value; }
        }

        // /// <summary>
        // /// Performs an implicit conversion from <see cref="T[]"/> to <see cref="Chess.DoubleIndexedProperty&lt;T&gt;"/>.
        // /// </summary>
        // /// <param name="value">The value.</param>
        // /// <returns>The result of the conversion.</returns>
        // public static implicit operator DoubleIndexedProperty<T>(T[,] value)
        // {
        //     return new DoubleIndexedProperty<T>(value);
        // }

        // /// <summary>
        // /// Performs an implicit conversion from <see cref="Chess.DoubleIndexedProperty&lt;T&gt;"/> to <see cref="T[]"/>.
        // /// </summary>
        // /// <param name="property">The property.</param>
        // /// <returns>The result of the conversion.</returns>
        // public static implicit operator T[,](DoubleIndexedProperty<T> property)
        // {
        //     return property.value;
        // }
    }
}